/******************************************************************************
 * @File name   :      ITempUserUsrGrpDaoImpl.java
 *
 * @Author      :      Brenda Yin
 *
 * @Date        :      2011-6-21
 *
 * @Copyright Notice: 
 * Copyright (c) 2014 DMS, Inc. All  Rights Reserved.
 * This software is published under the terms of the DMS Software
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file.
 * 
 * 
 * ----------------------------------------------------------------------------
 * Date                   Who        Version        Comments
 * 2011-6-21 下午04:47:27        Brenda Yin    1.0            Initial Version
 *****************************************************************************/
package com.cap.bts.framework.dm.employeemgnt.dao.impl;

             
import java.util.List;

import javax.inject.Inject;

import com.cap.bts.framework.dm.employeemgnt.dao.ITempUserUsrGrpDao;
import com.cap.bts.framework.dm.employeemgnt.domain.TempUserUsrGrp;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;

import com.cap.bts.framework.common.dao.impl.BaseDaoImpl;


/**
 *
 */
@Repository("tempUserUsrGrpDao")
public class TempUserUsrGrpDaoImpl extends BaseDaoImpl<TempUserUsrGrp, Long> implements ITempUserUsrGrpDao {

    /**
     * @Date        :      2011-6-21
     * @param clazz
     */
    @Inject
    public TempUserUsrGrpDaoImpl(
        @Value("com.cap.bts.framework.dm.employeemgnt.domain.TempUserUsrGrp")Class<TempUserUsrGrp> clazz) {
        super(clazz);
    }

    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      2011-6-21
     * @see com.cap.bts.dms.dm.approval.dao.ITempUserUsrGrpDao#getTempUserUsrGroupsByUserCode(java.lang.String)
    **/
    @Override
    public TempUserUsrGrp getTempUserUsrGroupsByUserId(Long userId) {
        String hql="from TempUserUsrGrp tuu where tuu.userId = ?1";
        List<TempUserUsrGrp> tempUserUsrGrpList=getListByQueryWithVaParam(hql,userId);
        if(null!=tempUserUsrGrpList&&tempUserUsrGrpList.size()>0){
            return tempUserUsrGrpList.get(0);
        }
        return null;
    }

    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      2011-6-22
     * @see com.cap.bts.dms.dm.approval.dao.ITempUserUsrGrpDao#deleteTempUserUsrGrpByGroupIdIdAndUserId(java.lang.Long, java.lang.Long)
    **/
    @Override
    public void deleteTempUserUsrGrpByGroupIdIdAndUserId(Long userGroupId, Long userId) {
        String deleteQueryStr = "delete from TempUserUsrGrp tuu where tuu.userGroupId = ?1 and tuu.userId = ?2";
        removeByQueryAndVaParam(deleteQueryStr, userGroupId, userId);
        
    }

    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      2011-6-29
     * @see com.cap.bts.dms.dm.employeemgnt.dao.ITempUserUsrGrpDao#deleteTempUserUsrGrpByUserId(java.lang.Long)
    **/
    @Override
    public void deleteTempUserUsrGrpByUserId(Long userId) {
        String hql = "delete from TempUserUsrGrp  where userId = " + userId;
        this.removeByQuery(hql);
        
        
    }

}
